<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="../../common/tag.jsp"%>
<%@ page isELIgnored="false" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">
<title>消息分析</title>
<style type="text/css">
.btn-primary:active {
	color: white;
	background-color: #576476;
}

.tableReportDate table {
	border-bottom: 1px solid #F4F5F9
}

.tableReportDate table td {
	border-top: 1px solid #F4F5F9
}
</style>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<link href="css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
<link href="css/style.min862f.css?v=4.1.0" rel="stylesheet">
<link href="css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
<link href="css/animate.min.css" rel="stylesheet">
<link href="css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
<link href="css/plugins/chosen/chosen.css" rel="stylesheet">
<link href="css/plugins/ionRangeSlider/ion.rangeSlider.css" rel="stylesheet">
<link href="css/plugins/ionRangeSlider/ion.rangeSlider.skinFlat.css" rel="stylesheet">
<link href="css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css" rel="stylesheet">
<link href="css/plugins/clockpicker/clockpicker.css" rel="stylesheet">  
<link href="css/style.min862f.css?v=4.1.0" rel="stylesheet">  
</head>
<body class="gray-bg">
	<div class="wrapper wrapper-content animated fadeInRight">
		<div class="row">
			<div class="col-sm-12">
				<div class="ibox float-e-margins">
					<div class="ibox-title">
						<h5>消息分析</h5>
					</div>
					<div class="ibox-content">
						<ul id="userAnalyzeTab" class="nav nav-tabs">
							<li class="active">
								<a href="#msgAnalyze" data-toggle="tab">
									 消息分析
								</a>
							</li>
							<li><a href="#msgKeywords" data-toggle="tab">消息关键字</a></li>
						</ul>
						<div id="userAnalyzeTabContent" class="tab-content">
						
							<div class="tab-pane fade in active" id="msgAnalyze">
								<!-- <div style="width:100%;height:40px;border:1px solid #B8B8B8;line-height:37px;padding-left:20px;font-size:14px;font-weight:bold;background-color:#F4F5F9;" >
									昨日关键指标
								</div> -->
								<div class="wrapper wrapper-content" style="background-color:	#F3F3F4;">
									<div id="tableBtnGroupDiv" class="btn-group" role="group" style="padding-top:20px;">
									  <button type="button" class="btn btn-default" style="color:white;background-color:#576476;" onclick="switchTableData('dayReport')">日报</button>
									  <button type="button" class="btn btn-default" onclick="switchTableData('weekReport')">周报</button>
									  <button type="button" class="btn btn-default" onclick="switchTableData('monthReport')">月报</button>
									</div>
									<div class="row">
										<div class="col-lg-4">
											<div class="ibox float-e-margins">
												<div class="ibox-title">
													<h5>消息发送人数</h5>
												</div>
												<div class="ibox-content">
													<h1 id="msgSendUserCount" class="no-margins" style="font-weight:bold;"><c:choose><c:when test="${not empty messageSendDayList[0].msg_user}">${messageSendDayList[0].msg_user}</c:when><c:otherwise>0</c:otherwise></c:choose></h1>
												</div>
											</div>
										</div>
										<div class="col-lg-4">
											<div class="ibox float-e-margins">
												<div class="ibox-title">
													<h5>消息发送次数</h5>
												</div>
												<div class="ibox-content">
													<h1 id="msgSendCount" class="no-margins" style="font-weight:bold;"><c:choose><c:when test="${not empty messageSendDayList[0].msg_count}">${messageSendDayList[0].msg_count}</c:when><c:otherwise>0</c:otherwise></c:choose></h1>
												</div>
											</div>
										</div>
										<div class="col-lg-4">
											<div class="ibox float-e-margins">
												<div class="ibox-title">
													<h5>人均发送次数</h5>
												</div>
												<div class="ibox-content">
													<h1 id="msgSendAvg" class="no-margins" style="font-weight:bold;"><c:choose><c:when test="${not empty messageSendDayList[0].msg_user && not empty messageSendDayList[0].msg_count}"><fmt:formatNumber type="number" value="${messageSendDayList[0].msg_count/messageSendDayList[0].msg_user}" maxFractionDigits="0"/></c:when><c:otherwise>0</c:otherwise></c:choose></h1>
												</div>
											</div>
										</div>
										
									</div>
									<div id="reportBtnGroupDiv" class="btn-group" role="group">
									  <button type="button" class="btn btn-default" style="color:white;background-color:#576476;" onclick="switchReport('weekReport')">周报</button>
									  <button type="button" class="btn btn-default" onclick="switchReport('monthReport')">月报</button>
									</div>
									<div class="row">
										<div class="col-lg-12">
											<div class="ibox float-e-margins">
												<div class="ibox-title">
													<h5>数据报表</h5>
												</div>
												<div class="jumbotron" style="background-color:white;display:inline-block;width:100%;">
												  <div id="msgReport" style="float:left;height:360px;width:100%;"></div>
												</div>
											</div>
										</div>
									</div>
									<div class="row">
										<div class="col-lg-12">
											<div id="tableOneBtnGroupDiv" class="btn-group" role="group">
											  <button type="button" class="btn btn-default" style="color:white;background-color:#576476;" onclick="switchTableDataOne('weekReport')">周报</button>
											  <button type="button" class="btn btn-default" onclick="switchTableDataOne('monthReport')">月报</button>
											</div>
											<div class="ibox float-e-margins">
												<div class="ibox-title" style="overflow:hidden">
													<h5 style="float:left;">数据表格</h5>
													<h5 style="float:right;"><button class="btn btn-info" id="button1">导出EXCEL</button></h5>
												</div>
												<div class="jumbotron" style="background-color:white;display:inline-block;width:100%;">
													<div class="tableReportDate">
														<table id="tableMsgSend" cellpadding="0px" cellspacing="0px" style="width:100%;text-align:right;">
														  </table>
													</div>
												</div>
											</div>
										</div>
									</div>
								</div>
							</div>
							<div class="tab-pane fade" id="msgKeywords">
								<div class="wrapper wrapper-content animated fadeInRight">
								    <div class="row">
								        <div class="col-sm-12">
								            <div class="ibox float-e-margins">
								                <!-- <div class="ibox-title">
								                    <h5>查询店铺二维码扫描记录</h5>
								                </div> -->
								                <div class="ibox-content">
								                    <form role="form" id="messageSendQueryForm" class="form-inline">
								                        <div class="form-group">
								                            <!-- <input type="text" id="keyword" name="keywordOne" class="form-control" placeholder="消息关键字"> -->
								                            <input class="form-control" type="text" style="width:150px;" id="keyword" name="keyword" placeholder="消息关键字"/>
								                        </div>
								                        
								                        <div class="form-group">
								                            <input id="paramStartTime" name="paramStartTime" class="form-control" type="text" readonly placeholder="发送开始时间">
								                        </div>
								                        
								                        <div class="form-group">
								                            <input id="paramEndTime" name="paramEndTime" class="form-control" type="text" readonly placeholder="发送结束时间">
								                        </div>
								                        
								                        <div class="input-group">
								                            <button class="btn btn-primary" type="button" style="margin-bottom: 0px;"
								                                    onclick="search();"><i class="fa fa-search"></i>&nbsp;查询
								                            </button>
								                        </div>
								                        
								                    </form>
								                </div>
								            </div>
								        </div>
								    </div>
								    <!-- Panel Other -->
								    <div class="ibox float-e-margins" id="tableShow">
								        <div class="ibox-content">
								            <div class="row row-lg">
								                <div class="col-sm-12">
								                    <!-- Example Events -->
								                    <div class="example-wrap">
								                        <table id="messageSendListTable" data-mobile-responsive="true"
								                               data-click-to-select="true" data-unique-id="id">
								                            <thead>
								                            </thead>
								                        </table>
								                    </div>
								                </div>
								                <!-- End Example Events -->
								            </div>
								        </div>
								    </div>
								</div>
								
								
								<!-- End Panel Other -->
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
</html>
<script src="js/jquery.min.js?v=2.1.4"></script>
<script src="js/bootstrap.min.js?v=3.3.6"></script>
<script src="js/content.min.js?v=1.0.0"></script>
<script src="js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
<script src="js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
<script src="js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<!--时间选择-->
<script src="js/plugins/layer/laydate/laydate.js"></script>
<!--下拉框-->
<script src="js/plugins/chosen/chosen.jquery.js"></script>
<script src="js/echarts.js"></script>
<script src="js/plugins/jquery-table2excel-master/src/jquery.table2excel.js"></script>

<script type="text/javascript">
//日期选择框
var start = {
	elem : "#paramStartTime",
	format : "YYYY-MM-DD hh:mm:ss",
	max : "2099-06-16",
	istime : true,
	istoday : false
};
var end = {
	elem : "#paramEndTime",
	format : "YYYY-MM-DD hh:mm:ss",
	max : "2099-06-16",
	istime : true,
	istoday : false
};
laydate(start);
laydate(end);

var $table = $('#messageSendListTable');

var search = function () {
    $table.bootstrapTable('refresh');
}

var config = {
    ".chosen-select": {},
    ".chosen-select-deselect": {allow_single_deselect: !0},
    ".chosen-select-no-single": {disable_search_threshold: 10},
    ".chosen-select-no-results": {no_results_text: "Oops, nothing found!"},
    ".chosen-select-width": {width: "95%"}
};

$(document).ready(function () {
    //将表单元素和table属性转成json
    queryParams = function (params) {
        var temp = {};
        temp.currentResult = params.offset;
        temp.showCount = params.limit;
        var formParam = $('#messageSendQueryForm').serializeArray();
        for (var i = 0; i < formParam.length; i++) {
            if (formParam[i].value != '') {
                temp[formParam[i].name] = formParam[i].value;
            }
        }
        return temp;
    };

    rowStyle = function (row, index) {
        var classes = ['info', 'success', 'info', 'warning', 'danger'];
        if (index % 2 === 0 && index / 2 < classes.length) {
            return {
                classes: classes[index / 2]
            };
        }
        return {};
    }

    $table.bootstrapTable({
    	type: "get",
        url: "messageAnalyze/getMsgSendVoList",
        pagination: !0,
        showRefresh: !0,
        showToggle: !0,
        showColumns: !0,
        iconSize: "outline",
        striped: true, //是否显示行间隔色
        queryParams: queryParams,//传递参数（*）
        sidePagination: "server", //服务端处理分页
        pageSize: 10,                       //每页的记录行数（*）
        pageList: [5, 10, 20, 50],        //可供选择的每页的行数（*）
        minimunCountColumns: 2,      //可供选择的每页的行数（*）
        //detailView: true,
        sortName: undefined,
        sortOrder: 'asc',
        sortStable: false,
        contentType: "application/json; charset=utf-8",
        rowStyle: rowStyle,
        iconsPrefix: 'glyphicon', // glyphicon of fa (font awesome)
        icons: {
            refresh: "glyphicon-repeat",
            toggle: "glyphicon-list-alt",
            columns: "glyphicon-list",
            detailOpen: 'glyphicon-plus icon-plus',
            detailClose: 'glyphicon-minus icon-minus',
            sortable: 'glyphicon-minus icon-minus'
        },
        onLoadSuccess: function (data) {
            if (data.total < 5) {
                $table.bootstrapTable('getOptions')["height"] = 400;
            } else {
                $table.bootstrapTable('getOptions')["height"] = '';
            }

            $table.bootstrapTable('hideColumn', 'id');
            $table.bootstrapTable('hideColumn', 'edit');
        },
        columns: [
             {
                title: '消息关键字',
                field: 'msgKeyword',
                align: 'center',
                valign: 'middle'
            },{
                title: '出现次数',
                field: 'showTimes',
                align: 'center',
                valign: 'middle'
            },{
                title: '占比',
                field: 'occupiesCompared',
                align: 'center',
                valign: 'middle',
                formatter: function (value, row, index) {
                	return '<div class="progress progress-striped" style="margin-bottom:0px;"><div class="progress-bar" style="width: '+row.occupiesCompared+'%;"><span>'+row.occupiesCompared+'%</span></div></div>';
                }
            }
        ]
    });
    for (var selector in config)$(selector).chosen(config[selector]);
});

function tableHeight() {
    return $(window).height() - 50;
}
</script>

<script type="text/javascript">
	//小时报
	var msgSendHourDate = [];
	var msgSendHourUserCountData = [];
	var msgSendHourCountData = [];
	var msgSendHourAvgData = [];
	//日报（昨天）
	var msgSendDayDate = [];
	var msgSendDayUserCountData = [];
	var msgSendDayCountData = [];
	var msgSendDayAvgData = [];
	//周报
	var msgSendWeekDate = [];
	var msgSendWeekUserCountData = [];
	var msgSendWeekCountData = [];
	var msgSendWeekAvgData = [];
	//月报
	var msgSendMonthDate = [];
	var msgSendMonthUserCountData = [];
	var msgSendMonthCountData = [];
	var msgSendMonthAvgData = [];
	
	<c:forEach items="${messageSendHourList}" var="messageSendHour">
		msgSendHourDate.push("${messageSendHour.ref_hour}")
		msgSendHourUserCountData.push(parseInt("${messageSendHour.msg_user}"))
		msgSendHourCountData.push(parseInt("${messageSendHour.msg_count}"))
	</c:forEach>
	for(var i = 0;i < msgSendHourDate.length;i++) {
		if(msgSendHourUserCountData[i] != null && msgSendHourUserCountData[i] != 0) {
			msgSendHourAvgData.push((parseFloat(msgSendHourCountData[i])/parseFloat(msgSendHourUserCountData[i])).toFixed(1))
		} else {
			msgSendHourAvgData.push(0);
		}
	}
		
	<c:forEach items="${messageSendDayList}" var="messageSendDay">
		msgSendDayDate.push("${messageSendDay.ref_date}")
		msgSendDayUserCountData.push(parseInt("${messageSendDay.msg_user}"))
		msgSendDayCountData.push(parseInt("${messageSendDay.msg_count}"))
	</c:forEach>
	for(var i = 0;i < msgSendDayDate.length;i++) {
		if(msgSendDayUserCountData[i] != null && msgSendDayUserCountData[i] != 0) {
			msgSendDayAvgData.push((parseFloat(msgSendDayCountData[i])/parseFloat(msgSendDayUserCountData[i])).toFixed(1))
		} else {
			msgSendDayAvgData.push(0);
		}
	}
		
	<c:forEach items="${messageSendWeekList}" var="messageSendWeek">
		msgSendWeekDate.push("${messageSendWeek.ref_date}")
		msgSendWeekUserCountData.push(parseInt("${messageSendWeek.msg_user}"))
		msgSendWeekCountData.push(parseInt("${messageSendWeek.msg_count}"))
	</c:forEach>
	for(var i = 0;i < msgSendWeekDate.length;i++) {
		if(msgSendWeekUserCountData[i] != null && msgSendWeekUserCountData[i] != 0) {
			msgSendWeekAvgData.push((parseFloat(msgSendWeekCountData[i])/parseFloat(msgSendWeekUserCountData[i])).toFixed(1))
		} else {
			msgSendWeekAvgData.push(0);
		}
	}
		
	<c:forEach items="${messageSendMonthList}" var="messageSendMonth">
		msgSendMonthDate.push("${messageSendMonth.ref_date}")
		msgSendMonthUserCountData.push(parseInt("${messageSendMonth.msg_user}"))
		msgSendMonthCountData.push(parseInt("${messageSendMonth.msg_count}"))
	</c:forEach>
	for(var i = 0;i < msgSendMonthDate.length;i++) {
		if(msgSendMonthUserCountData[i] != null && msgSendMonthUserCountData[i] != 0) {
			msgSendMonthAvgData.push((parseFloat(msgSendMonthCountData[i])/parseFloat(msgSendMonthUserCountData[i])).toFixed(1))
		} else {
			msgSendMonthAvgData.push(0);
		}
	}
	
	// 基于准备好的dom，初始化echarts实例
    var msgReportChart = echarts.init(document.getElementById('msgReport'));
	
    var msgOption = {
    	    title: {
    	        text: '周报堆叠区域图'
    	    },
    	    tooltip : {
    	        trigger: 'axis',
    	        axisPointer: {
    	            type: 'cross',
    	            label: {
    	                backgroundColor: '#6a7985'
    	            }
    	        }
    	    },
    	    legend: {
    	        data:['消息发送人数','消息发送次数','人均发送次数']
    	    },
    	    toolbox: {
    	    	show:true,
            	x:'95%',
    	        feature: {
    	            saveAsImage: {}
    	        }
    	    },
    	    grid: {
    	        left: '3%',
    	        right: '4%',
    	        bottom: '3%',
    	        containLabel: true
    	    },
    	    xAxis : [
    	        {
    	            type : 'category',
    	            boundaryGap : false,
    	            data : msgSendWeekDate
    	        }
    	    ],
    	    yAxis : [
    	        {
    	            type : 'value'
    	        }
    	    ],
    	    series : [
    	        {
    	            name:'消息发送人数',
    	            type:'line',
    	            stack: '总量',
    	            areaStyle: {normal: {}},
    	            data:msgSendWeekUserCountData
    	        },
    	        {
    	            name:'消息发送次数',
    	            type:'line',
    	            stack: '总量',
    	            areaStyle: {normal: {}},
    	            data:msgSendWeekCountData
    	        },
    	        {
    	            name:'人均发送次数',
    	            type:'line',
    	            stack: '总量',
    	            areaStyle: {normal: {}},
    	            data:msgSendWeekAvgData
    	        }
    	    ]
    	};
    
    msgReportChart.setOption(msgOption);
    
    //页面加载初始化底部表格数据
    var tableStr = "<tr><td>时间</td><td>消息发送人数</td><td>消息发送次数</td><td>人均发送次数</td></tr>";
	for(var i = 0;i < msgSendWeekDate.length;i++) {
		tableStr += "<tr><td>"+msgSendWeekDate[i]+"</td><td>"+msgSendWeekUserCountData[i]+"</td><td>"+msgSendWeekCountData[i]+"</td><td>"+msgSendWeekAvgData[i]+"</td></tr>";
	}
	$("#tableMsgSend").append(tableStr);
    
    //切换页面上部三框数据
	function switchTableData(reportType) {
		$("#tableBtnGroupDiv").children().removeAttr("style");
		if(reportType == "dayReport") {
			$("#tableBtnGroupDiv .btn:eq(0)").css("color","white");
			$("#tableBtnGroupDiv .btn:eq(0)").css("background-color","#576476");
			var msgSendUserCount = 0;
			var msgSendCount = 0;
			var msgSendAvg = 0;
			for(var i = 0;i < msgSendDayDate.length;i++) {
				msgSendUserCount += parseInt(msgSendHourUserCountData[i]);
				msgSendCount += parseInt(msgSendHourCountData[i]);
			}
			if(msgSendUserCount != null && msgSendUserCount != 0) {
				msgSendAvg = (parseFloat(msgSendCount)/parseFloat(msgSendUserCount)).toFixed(1);
			}
			$("#msgSendUserCount").text(msgSendUserCount);
			$("#msgSendCount").text(msgSendCount);
			$("#msgSendAvg").text(msgSendAvg);
		} else if(reportType == "weekReport") {
			$("#tableBtnGroupDiv .btn:eq(1)").css("color","white");
			$("#tableBtnGroupDiv .btn:eq(1)").css("background-color","#576476");
			var msgSendUserCount = 0;
			var msgSendCount = 0;
			var msgSendAvg = 0;
			for(var i = 0;i < msgSendWeekDate.length;i++) {
				msgSendUserCount += parseInt(msgSendWeekUserCountData[i]);
				msgSendCount += parseInt(msgSendWeekCountData[i]);
			}
			if(msgSendUserCount != null && msgSendUserCount != 0) {
				msgSendAvg = (parseFloat(msgSendCount)/parseFloat(msgSendUserCount)).toFixed(1);
			}
			$("#msgSendUserCount").text(msgSendUserCount);
			$("#msgSendCount").text(msgSendCount);
			$("#msgSendAvg").text(msgSendAvg);
		} else if(reportType == "monthReport") {
			$("#tableBtnGroupDiv .btn:eq(2)").css("color","white");
			$("#tableBtnGroupDiv .btn:eq(2)").css("background-color","#576476");
			var msgSendUserCount = 0;
			var msgSendCount = 0;
			var msgSendAvg = 0;
			for(var i = 0;i < msgSendMonthDate.length;i++) {
				msgSendUserCount += parseInt(msgSendMonthUserCountData[i]);
				msgSendCount += parseInt(msgSendMonthCountData[i]);
			}
			if(msgSendUserCount != null && msgSendUserCount != 0) {
				msgSendAvg = (parseFloat(msgSendCount)/parseFloat(msgSendUserCount)).toFixed(1);
			}
			$("#msgSendUserCount").text(msgSendUserCount);
			$("#msgSendCount").text(msgSendCount);
			$("#msgSendAvg").text(msgSendAvg);
		}
	}
	
	//切换报表数据
	function switchReport(reportType) {
		$("#reportBtnGroupDiv").children().removeAttr("style");
		
		if(reportType == "weekReport") {
			$("#reportBtnGroupDiv .btn:eq(0)").css("color","white");
			$("#reportBtnGroupDiv .btn:eq(0)").css("background-color","#576476");
			
			msgReportChart.setOption({        //加载数据图表
				title: {
	    	        text: '周报堆叠区域图'
	    	    },
	    	    xAxis: {
	                data: msgSendWeekDate
	            },
	    	    series : [
	    	        {
	    	            name:'消息发送人数',
	    	            data:msgSendWeekUserCountData
	    	        },
	    	        {
	    	            name:'消息发送次数',
	    	            data:msgSendWeekCountData
	    	        },
	    	        {
	    	            name:'人均发送次数',
	    	            data:msgSendWeekAvgData
	    	        }
	    	    ]
	        });
			
		} else if(reportType == "monthReport") {
			$("#reportBtnGroupDiv .btn:eq(1)").css("color","white");
			$("#reportBtnGroupDiv .btn:eq(1)").css("background-color","#576476");
			
			msgReportChart.setOption({        //加载数据图表
				title: {
	    	        text: '月报堆叠区域图'
	    	    },
	    	    xAxis: {
	                data: msgSendMonthDate
	            },
	    	    series : [
	    	        {
	    	            name:'消息发送人数',
	    	            data:msgSendMonthUserCountData
	    	        },
	    	        {
	    	            name:'消息发送次数',
	    	            data:msgSendMonthCountData
	    	        },
	    	        {
	    	            name:'人均发送次数',
	    	            data:msgSendMonthAvgData
	    	        }
	    	    ]
	        });
		}
	}
	
	//切换页面中最下面的表格数据
	function switchTableDataOne(reportType) {
		$("#tableOneBtnGroupDiv").children().removeAttr("style");
		
		if(reportType == "weekReport") {
			$("#tableOneBtnGroupDiv .btn:eq(0)").css("color","white");
			$("#tableOneBtnGroupDiv .btn:eq(0)").css("background-color","#576476");
			$("#tableMsgSend").html("");
			var tableStr = "<tr><td>时间</td><td>消息发送人数</td><td>消息发送次数</td><td>人均发送次数</td></tr>";
			for(var i = 0;i < msgSendWeekDate.length;i++) {
				tableStr += "<tr><td>"+msgSendWeekDate[i]+"</td><td>"+msgSendWeekUserCountData[i]+"</td><td>"+msgSendWeekCountData[i]+"</td><td>"+msgSendWeekAvgData[i]+"</td></tr>";
			}
			$("#tableMsgSend").append(tableStr);
		} else if(reportType == "monthReport") {
			$("#tableOneBtnGroupDiv .btn:eq(1)").css("color","white");
			$("#tableOneBtnGroupDiv .btn:eq(1)").css("background-color","#576476");
			$("#tableMsgSend").html("");
			var tableStr = "<tr><td>时间</td><td>消息发送人数</td><td>消息发送次数</td><td>人均发送次数</td></tr>";
			for(var i = 0;i < msgSendMonthDate.length;i++) {
				tableStr += "<tr><td>"+msgSendMonthDate[i]+"</td><td>"+msgSendMonthUserCountData[i]+"</td><td>"+msgSendMonthCountData[i]+"</td><td>"+msgSendMonthAvgData[i]+"</td></tr>";
			}
			$("#tableMsgSend").append(tableStr);
		}
	}
	
	$("#button1").click(function(){
	    $("#tableMsgSend").table2excel({
	        name: "Excel Document Name",
	        filename: "messageAnalyze"+Date.parse(new Date())+".xls",
	        exclude_img: true,
	        exclude_links: true,
	        exclude_inputs: true
	    });
	});
	
</script>